package com.xd.core.debt.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.pagehelper.Page;
import com.xd.core.api.dto.SinglePayDto;
import com.xd.core.api.entity.RepaymentOrderInfo;
import com.xd.core.api.vo.DebtByContractVo;
import com.xd.core.bill.dto.EarlyRepaymentQuery;
import com.xd.core.bill.vo.EarlyRepaymentPageVo;
import com.xd.core.business.dto.RepaymentScheduleDto;
import com.xd.core.business.vo.RepaymentInfoVo;
import com.xd.core.business.vo.RepaymentScheduleAppVo;
import com.xd.core.debt.dto.DebtOneDto;
import com.xd.core.debt.dto.DebtQuery;
import com.xd.core.debt.dto.InstallmentDebtQuery;
import com.xd.core.debt.entity.Debt;
import com.xd.core.debt.vo.*;
import com.xd.core.finance.dto.KeepBookingDto;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 债权管理对应表 Mapper 接口
 * </p>
 *
 * @author ZCH
 * @since 2025-02-26
 */
public interface DebtMapper extends BaseMapper<Debt> {

    Page<DebtPageVo> selectDebtList(@Param("debtQuery") DebtQuery debtQuery, @Param("companyId") Integer companyId, @Param("userIds") List<Integer> userIds);

    List<DebtInfoForTransVo> getBatchDebt(@Param("ids") List<Integer> ids);

    Page<EarlyRepaymentPageVo> selectEarlyRepaymentList(@Param("query") EarlyRepaymentQuery query, @Param("companyId") Integer companyId, @Param("userIds") List<Integer> userIds);

    OrgBorrowInfo getOrgBorrowInfo(@Param("id") Integer id);

    BillInfoNoOverdue getBillInfo(@Param("id") Integer id);

    void updateInterestAndPrincipal(List<Debt> debts);

    void updateFailCause(Integer id);

    List<SinglePayDto> selectSinglePayList();

    void updateRepaymentType(Integer id, String status);

    RepaymentInfoNoOverdue getRepaymentInfo(@Param("id") Integer id);

    RepaymentInfoOverdue getRepaymentInfoOverdue(@Param("id")Integer id);

    BillInfoOverdue getBillInfoOverdue(@Param("id")Integer id);

    List<SinglePayDto> selectEarlyPay();

    void updateRepaymentPeriods(Integer debtId, BigDecimal principal, BigDecimal interest, String remainingRepaymentPeriodsStatus, String isOverdue);

    void updateEarlyInfo(@Param("repaymentOrderInfo") RepaymentOrderInfo repaymentOrderInfo, @Param("repayAmount") BigDecimal repayAmount);

    void clearRepayTimes();

    List<Integer> isSameCompany(List<Integer> debtIds);

    void updatePurchaseAmountOfBonds(@Param("id") Integer id,@Param("purchaseAmountOfBonds") BigDecimal purchaseAmountOfBonds);

    List<DebtByContractVo> selectDebtByContract(List<Integer> debtIds);

    void updateConversionStatus(Integer outId);

    List<Integer> debtAutoRelease();

    void batchUpdateDebt(@Param("debtIds") List<Integer> debtIds);

    RepaymentInfoVo selectAmount(RepaymentScheduleDto repaymentScheduleDto);

    DebtDetailVo getDebtOne(@Param("dto") DebtOneDto dto);

    void updateAmount(KeepBookingDto keepBookingDto);

    void updateAmount1(KeepBookingDto keepBookingDto);

    AdvanceSurrenderInfo getAdvanceSurrenderInfo(Integer incomingId);

    Page<InstallmentDebtPageVo> getInstallmentDebtList(@Param("query") InstallmentDebtQuery query,@Param("companyId") Integer companyId);

    List<Debt> selectInsuranceList(List<Integer> outIds);

    List<Debt> selectInsuranceList1(List<Integer> outIds);

    RepaymentScheduleAppVo selectAppAmount(Integer incomingId);

    void updateByIncomingId(Integer incomingId);

    void updateAmountAfterSurrender(@Param("incomingId") Integer incomingId,@Param("totalPrincipal") BigDecimal totalPrincipal,@Param("totalInterest") BigDecimal totalInterest,@Param("remainingRepaymentPeriods") Integer remainingRepaymentPeriods);
}
